package compiler

import (
	"gitee.com/engino/flow/impl/defn"
	"gitee.com/engino/flow/process"
)

//AssignmentNode the node to execute a variable assignment.
type AssignmentNode struct {
	*defn.Assignment
}

//GetName get the name of the node.
func (n *AssignmentNode) GetName() string {
	return n.Name
}

//Execute execute the node.
func (n *AssignmentNode) Execute(inst process.Instance) error {
	for _, assignment := range n.AssignmentItems {
		inst.GetContext().Get(assignment.AssignTo).SetValue(assignment.Value)
	}
	return process.Continue(inst, n.Connector)
}
